package android.slc.app.shutdown;

import android.slc.jxbrowser.JxBrowserUtils;
import android.slc.rx.SimpleSingleObserver;
import io.reactivex.rxjava3.annotations.NonNull;
import io.reactivex.rxjava3.core.Single;
import io.reactivex.rxjava3.schedulers.Schedulers;
import javafx.application.Platform;

import java.util.concurrent.TimeUnit;

/**
 * @author slc
 * @date 2022/09/17 下午 5:36
 */
public class ShutdownManager {

    /**
     * 初始化
     */
    public static void shutdown() {
        JxBrowserUtils.closeCacheBrowser();
        Platform.exit();
        Single.timer(1000, TimeUnit.MILLISECONDS)
                .subscribeOn(Schedulers.io())
                .observeOn(Schedulers.io())
                .subscribe(new SimpleSingleObserver<>(){
                    @Override
                    public void onSuccess(@NonNull Long aLong) {
                        super.onSuccess(aLong);
                        System.exit(0);
                    }
                });
    }

}
